﻿using DesignPatterns.Prototype;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DesignPatterns.Decorator
{
    public partial class FrmPrototype : FrmBase
    {
        public List<Resume> Resumes { get; set; }

        public FrmPrototype()
        {
            InitializeComponent();

            Resumes = new List<Resume>();

            btnCloneResume.Click += BtnCloneResume_Click;
            btnShowAllResume.Click += BtnShowAllResume_Click;
        }

        private void BtnShowAllResume_Click(object sender, EventArgs e)
        {
            labResult.Text = "";
            foreach (var item in Resumes)
            {
                labResult.Text += item.Display() + "\n";
            }
        }

        private void BtnCloneResume_Click(object sender, EventArgs e)
        {
            if (Resumes.Count == 0)
            {
                var resume = new Resume(txtName.Text);
                resume.SetPersonalInfo(txtSex.Text, txtAge.Text);
                resume.SetWorkExperience(txtWorkDate.Text, txtCompany.Text);
                Resumes.Add(resume);

                txtName.Enabled = false;
                txtSex.Enabled = false;
                txtAge.Enabled = false;

                labResumeAmount.Text = "1";

                return;
            }

            var lastResume = Resumes.Last();
            var newResume = (Resume)lastResume.Clone();
            newResume.SetWorkExperience(txtWorkDate.Text, txtCompany.Text);
            Resumes.Add(newResume);
            labResumeAmount.Text = Resumes.Count.ToString();
        }
    }
}
